Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cucumber-expressions: Allow parentheses to be explicitly escaped #334

Merged
merged 2 commits into from
Feb 10, 2018

Conversation

jamis
Copy link
Contributor

@jamis jamis commented Feb 9, 2018

Summary

This allows parentheses to be explicitly escaped in cucumber expressions, so that they can be interpreted literally. This addresses issue #333.

Details

I changed OPTIONAL_REGEXP so that it looks for an optional escape character before the opening parenthesis. If found, the subsequent gsub will emit escaped parentheses, rather than the optional group.

It was necessary to look for a double-escaped parenthesis, though, because of how the ESCAPE_REGEXP was already escaping special characters.

Motivation and Context

The motivation is described in #333, but to summarize in brief, I am using Cucumber to describe an API in a platform-agnostic manner, for a book I am writing. I am using the Cucumber scenarios to describe function calls, which enclose parameter lists in parentheses. The cucumber expressions were not liking that very much.

How Has This Been Tested?

I added a spec that matches an expression with escaped parentheses, and showed that the expression was successfully parsed. All other tests continue to be green with this change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Thank you!

@jamis
Copy link
Contributor Author

jamis commented Feb 9, 2018

I think the build failure is unrelated to my change...

Failed to execute goal org.jacoco:jacoco-maven-plugin:0.7.7.201606060606:prepare-agent (pre-unit-test) on project tag-expressions: Execution pre-unit-test of goal org.jacoco:jacoco-maven-plugin:0.7.7.201606060606:prepare-agent failed: Plugin org.jacoco:jacoco-maven-plugin:0.7.7.201606060606 or one of its dependencies could not be resolved: Could not transfer artifact xerces:xercesImpl:jar:2.8.1 from/to central (https://repo.maven.apache.org/maven2): GET request of: xerces/xercesImpl/2.8.1/xercesImpl-2.8.1.jar from central failed: Connection reset -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

If you disagree, let me know and I'll investigate.

@aslakhellesoy
Copy link
Contributor

Thanks for the PR @jamis - the failure is indeed something unrelated (the joy of monorepos!).

I'll port your changes to Java and JavaScript.

@aslakhellesoy
Copy link
Contributor

Hi @jamis,

Thanks for your making your first contribution to Cucumber, and welcome to the Cucumber committers team! You can now push directly to this repo and all other repos under the cucumber organization! 🍾

In return for this generous offer we hope you will:

  • ✅ Continue to use branches and pull requests. When someone on the core team approves a pull request (yours or someone else's), you're welcome to merge it yourself.
  • 💚 Commit to setting a good example by following and upholding our code of conduct in your interactions with other collaborators and users.
  • 💬 Join the community Slack channel to meet the rest of the team and make yourself at home.
  • ℹ️ Don't feel obliged to help, just do what you can if you have the time and the energy.
  • 🙋 Ask if you need anything. We're looking for feedback about how to make the project more welcoming, so please tell us!

On behalf of the Cucumber core team,
Aslak Hellesøy
Creator of Cucumber

@lock
Copy link

lock bot commented Feb 10, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants